package com.manager.traffic.controller;

import com.manager.common.constant.TcpDataType;
import com.manager.common.customer.utils.RemoteExecute;
import com.manager.common.utils.DataTools;
import com.manager.common.vo.ResultVO;
import com.manager.model.TcpTraffic;
import com.manager.model.ZYNQSpecific;
import net.sf.json.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/tcpTraffic")
public class TcpTrafficController {

    @RequestMapping("/gather")
    public ResultVO gather(TcpTraffic model) {
        try{

            String url = DataTools.getSystemSettingStringValByKey("issue_instructions_url");
            JSONObject request = new JSONObject();
            request.put("code", TcpDataType.TCP_TRAFFIC_GATHER.getCode());

            JSONObject params = new JSONObject();
            params.put("time",model.getTime());
            String serialNumber = DataTools.getSerialNumber();
            params.put("serialNumber", serialNumber);

            request.put("content",params);

            RemoteExecute.executeTcpInstruction(url, request.toString());
            DataTools.putWebSessionId(serialNumber);
            return ResultVO.success();

        }catch (Exception e){
            e.printStackTrace();
        }
        return ResultVO.failed();
    }
}
